package b3.widget.home.bottom
{
	import b3.config.*;
	import b3.model.*;
	import b3.net.*;
	import b3.util.*;
	
	import flash.display.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.text.*;

	public class BuildingMessage extends Sprite
	{
		public function BuildingMessage(buildingIndex:int)
		{
			super();
			var buidlingConfig:BuildingConfig = Config.buildingConfigs[buildingIndex];
			var PopoutMsgBgr:Class = ResourceHelper.getInstance().getClassByName("PopoutMsgBgr2");
			var mainSprite:Sprite = new PopoutMsgBgr();
			mainSprite.alpha = 0.6;
			addChild(mainSprite);
			var me:Player = PlayerManager.getInstance().me;
			var currentRoofType:int = me.maxRoofType(buildingIndex);
			//操作
			var tipField:TextField = new TextField();
			tipField.selectable = false;
        	tipField.autoSize = TextFieldAutoSize.LEFT;
			tipField.defaultTextFormat = new TextFormat(BFont.fontName, 14, 0x00AA00, true);
			tipField.filters = [new GlowFilter(0xFFFFFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			tipField.x = 12;
			tipField.y = 10;
			if (currentRoofType >= 0)
			{
				tipField.htmlText = "点击开始建设";
			}
			else
			{
				if (buidlingConfig.type == BuildingConfig.GREEN)
					tipField.htmlText = "<font color='#FF0000'>光明值不足</font>";
				else if (buidlingConfig.type == BuildingConfig.WEAPON)
					tipField.htmlText = "<font color='#FF0000'>黑暗值不足</font>";
				else
					tipField.htmlText = "<font color='#FF0000'>城市人口不足</font>";
			}
			addChild(tipField);
			//具体信息
			var textField:TextField = new TextField();
			textField.selectable = false;
			textField.multiline = true;
        	textField.autoSize = TextFieldAutoSize.LEFT;
			textField.defaultTextFormat = new TextFormat(BFont.fontName, 14, 0xFFFFFF, true);
			textField.filters = [new GlowFilter(0x00AAFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			textField.x = 12;
			textField.y = 35; 
			if (currentRoofType >= 0)
			{
				textField.htmlText = "高度: " + buidlingConfig.height + "<br>占地: " + buidlingConfig.isoWidth + "×" + buidlingConfig.isoWidth 
					+ "<br>金币: " + BFont.formatNumWithComa(buidlingConfig.priceGoldCoin) + "<br>体力: " + buidlingConfig.vitalityCost;
			}
			else
			{
				if (buidlingConfig.type == BuildingConfig.GREEN)
					textField.htmlText = "需要光明值: <br>" + BFont.formatNumWithComa(buidlingConfig.roofUnlockPopulation[0]);
				else if (buidlingConfig.type == BuildingConfig.WEAPON)
					textField.htmlText = "需要黑暗值: <br>" + BFont.formatNumWithComa(buidlingConfig.roofUnlockPopulation[0]);
				else
					textField.htmlText = "需要城市人口: <br>" + BFont.formatNumWithComa(buidlingConfig.roofUnlockPopulation[0]);
			}
			addChild(textField);
		}
	}
}